--------------------------------------------------------------------------------
      name:  <unnamed>
       log:  R:\Current Research\Markets-Pridemore\Work\MAR09-DescGraph.log
  log type:  text
 opened on:   1 Jul 2024, 16:07:13

. 
. //  program:    Stata 
. //  task:       Cross-Sectional Models 
. //  project:    Markets  
. 
. version
version 17.0

. clear all

. macro drop _all

. set linesize 80

. set more off

. local tag " 06-29-24| Cleaned 06-29-24"

. local file "MAR09-DescGraph"

. local note "|`tag' | `file'"

. local opt "noparen sideway excel noaster  bdec(2)  sdec(2)  pdec(3)   adec(2) 
> e(r2) stats(coef se pval)"

. local dv "lrhom"

. local iv "fraser"

. local iv2 "infantmort" 

. local cont "edu unemp  popdense perurban  sexratio"

. 
. //      #0
. //      loading data 
. use MAR08-CondtionModel.dta, clear 

. 
. //      #1
. //      Sample
. tab nation 

                           Country Name |      Freq.     Percent        Cum.
----------------------------------------+-----------------------------------
                                Albania |          8        0.52        0.52
                              Argentina |         20        1.31        1.84
                                Armenia |         14        0.92        2.76
                              Australia |         19        1.25        4.00
                                Austria |         20        1.31        5.31
                                Bahamas |         16        1.05        6.36
                                Bahrain |          7        0.46        6.82
                               Barbados |         13        0.85        7.68
                                Belgium |         19        1.25        8.92
                                 Belize |         17        1.12       10.04
                                 Brazil |         20        1.31       11.35
                      Brunei Darussalam |          7        0.46       11.81
                               Bulgaria |         20        1.31       13.12
                                 Canada |         20        1.31       14.44
                                  Chile |         20        1.31       15.75
                               Colombia |         20        1.31       17.06
                             Costa Rica |         20        1.31       18.37
                                Croatia |         19        1.25       19.62
                                 Cyprus |         17        1.12       20.73
                                Czechia |         20        1.31       22.05
                                Denmark |         20        1.31       23.36
                     Dominican Republic |         19        1.25       24.61
                                Ecuador |         20        1.31       25.92
                                  Egypt |         20        1.31       27.23
                            El Salvador |         19        1.25       28.48
                                Estonia |         20        1.31       29.79
                                   Fiji |         11        0.72       30.51
                                Finland |         20        1.31       31.82
                                 France |         18        1.18       33.01
                                Georgia |         16        1.05       34.06
                                Germany |         20        1.31       35.37
                                 Greece |         20        1.31       36.68
                              Guatemala |         20        1.31       37.99
                                 Guyana |         19        1.25       39.24
                                Hungary |         20        1.31       40.55
                                Iceland |         18        1.18       41.73
                                Ireland |         17        1.12       42.85
                                 Israel |         20        1.31       44.16
                                  Italy |         20        1.31       45.47
                                Jamaica |         13        0.85       46.33
                                  Japan |         20        1.31       47.64
                                 Jordan |          9        0.59       48.23
                             Kazakhstan |         15        0.98       49.21
                                 Kuwait |         20        1.31       50.52
                             Kyrgyzstan |         15        0.98       51.51
                                 Latvia |         20        1.31       52.82
                              Lithuania |         20        1.31       54.13
                             Luxembourg |         20        1.31       55.45
                               Malaysia |         20        1.31       56.76
                                  Malta |         16        1.05       57.81
                              Mauritius |         20        1.31       59.12
                                 Mexico |         20        1.31       60.43
                             Montenegro |          6        0.39       60.83
                            Netherlands |         20        1.31       62.14
                            New Zealand |         17        1.12       63.25
                              Nicaragua |         15        0.98       64.24
                        North Macedonia |         16        1.05       65.29
                                 Norway |         17        1.12       66.40
                                   Oman |          6        0.39       66.80
                                 Panama |         20        1.31       68.11
                               Paraguay |         20        1.31       69.42
                                   Peru |         20        1.31       70.73
                            Philippines |         15        0.98       71.72
                                 Poland |         20        1.31       73.03
                               Portugal |         17        1.12       74.15
                                  Qatar |          9        0.59       74.74
                      Republic of Korea |         20        1.31       76.05
                    Republic of Moldova |         14        0.92       76.97
                                Romania |         20        1.31       78.28
                     Russian Federation |         20        1.31       79.59
                                 Serbia |         15        0.98       80.58
                              Singapore |         20        1.31       81.89
                               Slovakia |         16        1.05       82.94
                               Slovenia |         20        1.31       84.25
                           South Africa |         19        1.25       85.50
                                  Spain |         20        1.31       86.81
                              Sri Lanka |         14        0.92       87.73
                                 Sweden |         19        1.25       88.98
                            Switzerland |         20        1.31       90.29
                   Syrian Arab Republic |         11        0.72       91.01
                               Thailand |         19        1.25       92.26
                    Trinidad and Tobago |         13        0.85       93.11
                                 Turkey |         11        0.72       93.83
                                Ukraine |         18        1.18       95.01
United Kingdom of Great Britain and N.. |         20        1.31       96.33
               United States of America |         20        1.31       97.64
                                Uruguay |         19        1.25       98.88
     Venezuela (Bolivarian Republic of) |         17        1.12      100.00
----------------------------------------+-----------------------------------
                                  Total |      1,524      100.00

. 
. //      #2
. //      correlations 
. cor `dv' `iv' `iv2' `cont' 
(obs=1,524)

             |    lrhom   fraser infant~t      edu    unemp popdense perurban
-------------+---------------------------------------------------------------
       lrhom |   1.0000
      fraser |  -0.3808   1.0000
  infantmort |   0.5628  -0.4719   1.0000
         edu |  -0.4535   0.5160  -0.7414   1.0000
       unemp |   0.0936  -0.1604   0.1866  -0.0696   1.0000
    popdense |  -0.1947   0.2295  -0.1365   0.0265  -0.1237   1.0000
    perurban |  -0.2445   0.2983  -0.4809   0.4185  -0.1790   0.2131   1.0000
    sexratio |  -0.2370  -0.0479  -0.0045  -0.1529  -0.2035   0.0734   0.2091

             | sexratio
-------------+---------
    sexratio |   1.0000


. 
. //      #3
. //      descriptive
. tabstat `dv' `iv' `iv2' `cont' rhom, stats(min max p50 mean sd) 

   Stats |     lrhom    fraser  infant~t       edu     unemp  popdense  perurban
---------+----------------------------------------------------------------------
     Min | -3.687449      2.75       1.6  .3580358        .1  2.493134    18.196
     Max |  4.458272      8.85      49.4  1.064461     37.25  8044.526       100
     p50 |  .5565609      7.46       7.3  .7489494      6.99  85.09023    71.633
    Mean |  .8894628  7.306896  10.49278   .745701  8.207925  232.3275  69.75805
      SD |  1.412647  .7883708  8.422201  .1175076  5.376688  813.7406  17.26242
--------------------------------------------------------------------------------

   Stats |  sexratio      rhom
---------+--------------------
     Min |  84.46587  .0250358
     Max |  329.3863  86.33823
     p50 |  97.19975  1.744663
    Mean |  99.21878  6.490126
      SD |  19.35483  10.47036
------------------------------

. 
. //      #4
. //      WVS measure
. preserve 

. use WVS-06-29-2024.dta, clear 

. tab S002VS

 Chronology |
 of EVS-WVS |
      waves |      Freq.     Percent        Cum.
------------+-----------------------------------
  1981-1984 |     10,307        2.32        2.32
  1989-1993 |     24,558        5.54        7.86
  1994-1998 |     77,818       17.55       25.41
  1999-2004 |     60,045       13.54       38.95
  2005-2009 |     83,975       18.94       57.88
  2010-2014 |     89,565       20.20       78.08
  2017-2022 |     97,220       21.92      100.00
------------+-----------------------------------
      Total |    443,488      100.00

. tab S002VS, nolab

 Chronology |
 of EVS-WVS |
      waves |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     10,307        2.32        2.32
          2 |     24,558        5.54        7.86
          3 |     77,818       17.55       25.41
          4 |     60,045       13.54       38.95
          5 |     83,975       18.94       57.88
          6 |     89,565       20.20       78.08
          7 |     97,220       21.92      100.00
------------+-----------------------------------
      Total |    443,488      100.00

. drop if S002VS<4
(112,683 observations deleted)

. tab S002VS

 Chronology |
 of EVS-WVS |
      waves |      Freq.     Percent        Cum.
------------+-----------------------------------
  1999-2004 |     60,045       18.15       18.15
  2005-2009 |     83,975       25.39       43.54
  2010-2014 |     89,565       27.07       70.61
  2017-2022 |     97,220       29.39      100.00
------------+-----------------------------------
      Total |    330,805      100.00

. tab A165

Most people can be trusted |      Freq.     Percent        Cum.
---------------------------+-----------------------------------
                 Not asked |      2,988        0.90        0.90
                 No answer |      2,829        0.86        1.76
                Don't know |      6,313        1.91        3.67
Most people can be trusted |     81,577       24.66       28.33
   Need to be very careful |    237,098       71.67      100.00
---------------------------+-----------------------------------
                     Total |    330,805      100.00

. tab A165, nolab

Most people |
     can be |
    trusted |      Freq.     Percent        Cum.
------------+-----------------------------------
         -4 |      2,988        0.90        0.90
         -2 |      2,829        0.86        1.76
         -1 |      6,313        1.91        3.67
          1 |     81,577       24.66       28.33
          2 |    237,098       71.67      100.00
------------+-----------------------------------
      Total |    330,805      100.00

. drop if A165<0
(12,130 observations deleted)

. gen trust=1 if A165==1
(237,098 missing values generated)

. replace trust=0 if A165==2
(237,098 real changes made)

. gen notrust=1 if A165==2
(81,577 missing values generated)

. replace notrust=0 if A165==1
(81,577 real changes made)

. tab COW_ALPHA

CoW country |
 code alpha |      Freq.     Percent        Cum.
------------+-----------------------------------
        ALB |        952        0.30        0.30
        ALG |      2,379        0.75        1.05
        AND |      1,995        0.63        1.67
        ARG |      4,179        1.31        2.98
        ARM |      2,306        0.72        3.71
        AUL |      4,661        1.46        5.17
        AZE |        973        0.31        5.47
        BFO |      1,443        0.45        5.93
        BLR |      1,419        0.45        6.37
        BNG |      2,682        0.84        7.21
        BOL |      2,047        0.64        7.86
        BOS |      1,185        0.37        8.23
        BRA |      4,683        1.47        9.70
        BUL |        883        0.28        9.97
        CAN |      8,035        2.52       12.50
        CHL |      4,098        1.29       13.78
        CHN |      8,017        2.52       16.30
        COL |      6,014        1.89       18.18
        CYP |      2,986        0.94       19.12
        CZR |      1,191        0.37       19.50
        DRV |      3,601        1.13       20.63
        ECU |      2,377        0.75       21.37
        EGY |      8,730        2.74       24.11
        EST |      1,491        0.47       24.58
        ETH |      2,540        0.80       25.38
        FIN |      1,000        0.31       25.69
        FRN |        996        0.31       26.00
        GHA |      3,079        0.97       26.97
        GMY |      5,397        1.69       28.66
        GRC |      1,188        0.37       29.03
        GRG |      2,648        0.83       29.87
        GUA |      2,224        0.70       30.56
        HAI |      1,967        0.62       31.18
        HKG |      4,289        1.35       32.53
        HUN |        988        0.31       32.84
        IND |      9,200        2.89       35.72
        INS |      5,859        1.84       37.56
        IRN |      6,065        1.90       39.47
        IRQ |      7,105        2.23       41.70
        ISR |      1,168        0.37       42.06
        ITA |        953        0.30       42.36
        JOR |      4,784        1.50       43.86
        JPN |      5,826        1.83       45.69
        KEN |      1,252        0.39       46.08
        KUW |      1,240        0.39       46.47
        KYR |      3,658        1.15       47.62
        KZK |      2,718        0.85       48.47
        LEB |      2,282        0.72       49.19
        LIB |      3,184        1.00       50.19
        MAC |      1,021        0.32       50.51
        MAD |      1,027        0.32       50.83
        MAL |      3,814        1.20       52.03
        MAU |        968        0.30       52.33
        MEX |      6,779        2.13       54.46
        MLD |      2,000        0.63       55.09
        MLI |      1,303        0.41       55.50
        MNG |      1,035        0.32       55.82
        MON |      1,633        0.51       56.33
        MOR |      4,764        1.49       57.83
        MYA |      1,200        0.38       58.20
        NEW |      2,729        0.86       59.06
        NIC |      1,200        0.38       59.44
        NIG |      4,990        1.57       61.00
       NIRL |        437        0.14       61.14
        NOR |      1,018        0.32       61.46
        NTH |      4,803        1.51       62.97
        PAK |      4,959        1.56       64.52
        PER |      5,561        1.75       66.27
        PHI |      3,578        1.12       67.39
        POL |      1,900        0.60       67.99
        PRI |      1,828        0.57       68.56
        PSE |        892        0.28       68.84
        QAT |      1,059        0.33       69.17
        ROK |      4,822        1.51       70.69
        ROM |      4,411        1.38       72.07
        RUS |      6,019        1.89       73.96
        RWA |      3,026        0.95       74.91
        SAF |      6,469        2.03       76.94
        SAU |      1,431        0.45       77.39
        SIN |      5,462        1.71       79.10
        SLO |      1,190        0.37       79.47
        SLV |      2,058        0.65       80.12
        SPN |      3,501        1.10       81.22
        SRB |      3,283        1.03       82.25
        SWD |      3,109        0.98       83.22
        SWZ |      1,187        0.37       83.60
        TAJ |      1,200        0.38       83.97
        TAW |      3,659        1.15       85.12
        TAZ |      1,112        0.35       85.47
        THI |      4,135        1.30       86.77
        TRI |      1,994        0.63       87.39
        TUN |      2,341        0.73       88.13
        TUR |      8,578        2.69       90.82
        UGA |        998        0.31       91.13
        UKG |      3,589        1.13       92.26
        UKR |      3,550        1.11       93.37
        URU |      2,766        0.87       94.24
        USA |      7,227        2.27       96.51
        UZB |      2,686        0.84       97.35
        VEN |      2,383        0.75       98.10
        YEM |        953        0.30       98.40
        ZAM |      1,403        0.44       98.84
        ZIM |      3,698        1.16      100.00
------------+-----------------------------------
      Total |    318,675      100.00

. collapse (mean) trust notrust (firstnm) COW_ALPHA COW_NUM, by( S003)

. sum trust

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       trust |        103    .2460819    .1493347   .0351053   .7416503

. sum trust notrust

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       trust |        103    .2460819    .1493347   .0351053   .7416503
     notrust |        103    .7539181    .1493347   .2583497   .9648947

. rename COW_ALPHA countrycode 

. gen CID=.
(103 missing values generated)

. do 00-CID-CountryCode.do

. replace CID=    4       if countrycode=="AFG"
(0 real changes made)

. replace CID=    248     if countrycode=="ALA"
(0 real changes made)

. replace CID=    8       if countrycode=="ALB"
(1 real change made)

. replace CID=    12      if countrycode=="DZA"
(0 real changes made)

. replace CID=    16      if countrycode=="ASM"
(0 real changes made)

. replace CID=    20      if countrycode=="AND"
(1 real change made)

. replace CID=    24      if countrycode=="AGO"
(0 real changes made)

. replace CID=    660     if countrycode=="AIA"
(0 real changes made)

. replace CID=    10      if countrycode=="ATA"
(0 real changes made)

. replace CID=    28      if countrycode=="ATG"
(0 real changes made)

. replace CID=    32      if countrycode=="ARG"
(1 real change made)

. replace CID=    51      if countrycode=="ARM"
(1 real change made)

. replace CID=    533     if countrycode=="ABW"
(0 real changes made)

. replace CID=    36      if countrycode=="AUS"
(0 real changes made)

. replace CID=    40      if countrycode=="AUT"
(0 real changes made)

. replace CID=    31      if countrycode=="AZE"
(1 real change made)

. replace CID=    44      if countrycode=="BHS"
(0 real changes made)

. replace CID=    48      if countrycode=="BHR"
(0 real changes made)

. replace CID=    50      if countrycode=="BGD"
(0 real changes made)

. replace CID=    52      if countrycode=="BRB"
(0 real changes made)

. replace CID=    112     if countrycode=="BLR"
(1 real change made)

. replace CID=    56      if countrycode=="BEL"
(0 real changes made)

. replace CID=    84      if countrycode=="BLZ"
(0 real changes made)

. replace CID=    204     if countrycode=="BEN"
(0 real changes made)

. replace CID=    60      if countrycode=="BMU"
(0 real changes made)

. replace CID=    64      if countrycode=="BTN"
(0 real changes made)

. replace CID=    68      if countrycode=="BOL"
(1 real change made)

. replace CID=    70      if countrycode=="BIH"
(0 real changes made)

. replace CID=    72      if countrycode=="BWA"
(0 real changes made)

. replace CID=    74      if countrycode=="BVT"
(0 real changes made)

. replace CID=    76      if countrycode=="BRA"
(1 real change made)

. replace CID=    86      if countrycode=="IOT"
(0 real changes made)

. replace CID=    92      if countrycode=="VGB"
(0 real changes made)

. replace CID=    96      if countrycode=="BRN"
(0 real changes made)

. replace CID=    100     if countrycode=="BGR"
(0 real changes made)

. replace CID=    854     if countrycode=="BFA"
(0 real changes made)

. replace CID=    108     if countrycode=="BDI"
(0 real changes made)

. replace CID=    116     if countrycode=="KHM"
(0 real changes made)

. replace CID=    120     if countrycode=="CMR"
(0 real changes made)

. replace CID=    124     if countrycode=="CAN"
(1 real change made)

. replace CID=    132     if countrycode=="CPV"
(0 real changes made)

. replace CID=    136     if countrycode=="CYM"
(0 real changes made)

. replace CID=    140     if countrycode=="CAF"
(0 real changes made)

. replace CID=    148     if countrycode=="TCD"
(0 real changes made)

. replace CID=    152     if countrycode=="CHL"
(1 real change made)

. replace CID=    156     if countrycode=="CHN"
(1 real change made)

. replace CID=    162     if countrycode=="CXR"
(0 real changes made)

. replace CID=    166     if countrycode=="CCK"
(0 real changes made)

. replace CID=    170     if countrycode=="COL"
(1 real change made)

. replace CID=    174     if countrycode=="COM"
(0 real changes made)

. replace CID=    178     if countrycode=="COG"
(0 real changes made)

. replace CID=    180     if countrycode=="COD"
(0 real changes made)

. replace CID=    184     if countrycode=="COK"
(0 real changes made)

. replace CID=    188     if countrycode=="CRI"
(0 real changes made)

. replace CID=    191     if countrycode=="HRV"
(0 real changes made)

. replace CID=    192     if countrycode=="CUB"
(0 real changes made)

. replace CID=    196     if countrycode=="CYP"
(1 real change made)

. replace CID=    203     if countrycode=="CZE"
(0 real changes made)

. replace CID=    384     if countrycode=="CIV"
(0 real changes made)

. replace CID=    208     if countrycode=="DNK"
(0 real changes made)

. replace CID=    262     if countrycode=="DJI"
(0 real changes made)

. replace CID=    212     if countrycode=="DMA"
(0 real changes made)

. replace CID=    214     if countrycode=="DOM"
(0 real changes made)

. replace CID=    218     if countrycode=="ECU"
(1 real change made)

. replace CID=    818     if countrycode=="EGY"
(1 real change made)

. replace CID=    222     if countrycode=="SLV"
(1 real change made)

. replace CID=    226     if countrycode=="GNQ"
(0 real changes made)

. replace CID=    232     if countrycode=="ERI"
(0 real changes made)

. replace CID=    233     if countrycode=="EST"
(1 real change made)

. replace CID=    231     if countrycode=="ETH"
(1 real change made)

. replace CID=    238     if countrycode=="FLK"
(0 real changes made)

. replace CID=    234     if countrycode=="FRO"
(0 real changes made)

. replace CID=    242     if countrycode=="FJI"
(0 real changes made)

. replace CID=    246     if countrycode=="FIN"
(1 real change made)

. replace CID=    250     if countrycode=="FRA"
(0 real changes made)

. replace CID=    254     if countrycode=="GUF"
(0 real changes made)

. replace CID=    258     if countrycode=="PYF"
(0 real changes made)

. replace CID=    260     if countrycode=="ATF"
(0 real changes made)

. replace CID=    266     if countrycode=="GAB"
(0 real changes made)

. replace CID=    270     if countrycode=="GMB"
(0 real changes made)

. replace CID=    268     if countrycode=="GEO"
(0 real changes made)

. replace CID=    276     if countrycode=="DEU"
(0 real changes made)

. replace CID=    288     if countrycode=="GHA"
(1 real change made)

. replace CID=    292     if countrycode=="GIB"
(0 real changes made)

. replace CID=    300     if countrycode=="GRC"
(1 real change made)

. replace CID=    304     if countrycode=="GRL"
(0 real changes made)

. replace CID=    308     if countrycode=="GRD"
(0 real changes made)

. replace CID=    312     if countrycode=="GLP"
(0 real changes made)

. replace CID=    316     if countrycode=="GUM"
(0 real changes made)

. replace CID=    320     if countrycode=="GTM"
(0 real changes made)

. replace CID=    831     if countrycode=="GGY"
(0 real changes made)

. replace CID=    324     if countrycode=="GIN"
(0 real changes made)

. replace CID=    624     if countrycode=="GNB"
(0 real changes made)

. replace CID=    328     if countrycode=="GUY"
(0 real changes made)

. replace CID=    332     if countrycode=="HTI"
(0 real changes made)

. replace CID=    334     if countrycode=="HMD"
(0 real changes made)

. replace CID=    336     if countrycode=="VAT"
(0 real changes made)

. replace CID=    340     if countrycode=="HND"
(0 real changes made)

. replace CID=    344     if countrycode=="HKG"
(1 real change made)

. replace CID=    348     if countrycode=="HUN"
(1 real change made)

. replace CID=    352     if countrycode=="ISL"
(0 real changes made)

. replace CID=    356     if countrycode=="IND"
(1 real change made)

. replace CID=    360     if countrycode=="IDN"
(0 real changes made)

. replace CID=    364     if countrycode=="IRN"
(1 real change made)

. replace CID=    368     if countrycode=="IRQ"
(1 real change made)

. replace CID=    372     if countrycode=="IRL"
(0 real changes made)

. replace CID=    833     if countrycode=="IMN"
(0 real changes made)

. replace CID=    376     if countrycode=="ISR"
(1 real change made)

. replace CID=    380     if countrycode=="ITA"
(1 real change made)

. replace CID=    388     if countrycode=="JAM"
(0 real changes made)

. replace CID=    392     if countrycode=="JPN"
(1 real change made)

. replace CID=    832     if countrycode=="JEY"
(0 real changes made)

. replace CID=    400     if countrycode=="JOR"
(1 real change made)

. replace CID=    398     if countrycode=="KAZ"
(0 real changes made)

. replace CID=    404     if countrycode=="KEN"
(1 real change made)

. replace CID=    296     if countrycode=="KIR"
(0 real changes made)

. replace CID=    408     if countrycode=="PRK"
(0 real changes made)

. replace CID=    410     if countrycode=="KOR"
(0 real changes made)

. replace CID=    414     if countrycode=="KWT"
(0 real changes made)

. replace CID=    417     if countrycode=="KGZ"
(0 real changes made)

. replace CID=    418     if countrycode=="LAO"
(0 real changes made)

. replace CID=    428     if countrycode=="LVA"
(0 real changes made)

. replace CID=    422     if countrycode=="LBN"
(0 real changes made)

. replace CID=    426     if countrycode=="LSO"
(0 real changes made)

. replace CID=    430     if countrycode=="LBR"
(0 real changes made)

. replace CID=    434     if countrycode=="LBY"
(0 real changes made)

. replace CID=    438     if countrycode=="LIE"
(0 real changes made)

. replace CID=    440     if countrycode=="LTU"
(0 real changes made)

. replace CID=    442     if countrycode=="LUX"
(0 real changes made)

. replace CID=    446     if countrycode=="MAC"
(1 real change made)

. replace CID=    807     if countrycode=="MKD"
(0 real changes made)

. replace CID=    450     if countrycode=="MDG"
(0 real changes made)

. replace CID=    454     if countrycode=="MWI"
(0 real changes made)

. replace CID=    458     if countrycode=="MYS"
(0 real changes made)

. replace CID=    462     if countrycode=="MDV"
(0 real changes made)

. replace CID=    466     if countrycode=="MLI"
(1 real change made)

. replace CID=    470     if countrycode=="MLT"
(0 real changes made)

. replace CID=    584     if countrycode=="MHL"
(0 real changes made)

. replace CID=    474     if countrycode=="MTQ"
(0 real changes made)

. replace CID=    478     if countrycode=="MRT"
(0 real changes made)

. replace CID=    480     if countrycode=="MUS"
(0 real changes made)

. replace CID=    175     if countrycode=="MYT"
(0 real changes made)

. replace CID=    484     if countrycode=="MEX"
(1 real change made)

. replace CID=    583     if countrycode=="FSM"
(0 real changes made)

. replace CID=    498     if countrycode=="MDA"
(0 real changes made)

. replace CID=    492     if countrycode=="MCO"
(0 real changes made)

. replace CID=    496     if countrycode=="MNG"
(1 real change made)

. replace CID=    499     if countrycode=="MNE"
(0 real changes made)

. replace CID=    500     if countrycode=="MSR"
(0 real changes made)

. replace CID=    504     if countrycode=="MAR"
(0 real changes made)

. replace CID=    508     if countrycode=="MOZ"
(0 real changes made)

. replace CID=    104     if countrycode=="MMR"
(0 real changes made)

. replace CID=    516     if countrycode=="NAM"
(0 real changes made)

. replace CID=    520     if countrycode=="NRU"
(0 real changes made)

. replace CID=    524     if countrycode=="NPL"
(0 real changes made)

. replace CID=    528     if countrycode=="NLD"
(0 real changes made)

. replace CID=    530     if countrycode=="ANT"
(0 real changes made)

. replace CID=    540     if countrycode=="NCL"
(0 real changes made)

. replace CID=    554     if countrycode=="NZL"
(0 real changes made)

. replace CID=    558     if countrycode=="NIC"
(1 real change made)

. replace CID=    562     if countrycode=="NER"
(0 real changes made)

. replace CID=    566     if countrycode=="NGA"
(0 real changes made)

. replace CID=    570     if countrycode=="NIU"
(0 real changes made)

. replace CID=    574     if countrycode=="NFK"
(0 real changes made)

. replace CID=    580     if countrycode=="MNP"
(0 real changes made)

. replace CID=    578     if countrycode=="NOR"
(1 real change made)

. replace CID=    512     if countrycode=="OMN"
(0 real changes made)

. replace CID=    586     if countrycode=="PAK"
(1 real change made)

. replace CID=    585     if countrycode=="PLW"
(0 real changes made)

. replace CID=    275     if countrycode=="PSE"
(1 real change made)

. replace CID=    591     if countrycode=="PAN"
(0 real changes made)

. replace CID=    598     if countrycode=="PNG"
(0 real changes made)

. replace CID=    600     if countrycode=="PRY"
(0 real changes made)

. replace CID=    604     if countrycode=="PER"
(1 real change made)

. replace CID=    608     if countrycode=="PHL"
(0 real changes made)

. replace CID=    612     if countrycode=="PCN"
(0 real changes made)

. replace CID=    616     if countrycode=="POL"
(1 real change made)

. replace CID=    620     if countrycode=="PRT"
(0 real changes made)

. replace CID=    630     if countrycode=="PRI"
(1 real change made)

. replace CID=    634     if countrycode=="QAT"
(1 real change made)

. replace CID=    642     if countrycode=="ROU"
(0 real changes made)

. replace CID=    643     if countrycode=="RUS"
(1 real change made)

. replace CID=    646     if countrycode=="RWA"
(1 real change made)

. replace CID=    638     if countrycode=="REU"
(0 real changes made)

. replace CID=    654     if countrycode=="SHN"
(0 real changes made)

. replace CID=    659     if countrycode=="KNA"
(0 real changes made)

. replace CID=    662     if countrycode=="LCA"
(0 real changes made)

. replace CID=    666     if countrycode=="SPM"
(0 real changes made)

. replace CID=    670     if countrycode=="VCT"
(0 real changes made)

. replace CID=    652     if countrycode=="BLM"
(0 real changes made)

. replace CID=    663     if countrycode=="MAF"
(0 real changes made)

. replace CID=    882     if countrycode=="WSM"
(0 real changes made)

. replace CID=    674     if countrycode=="SMR"
(0 real changes made)

. replace CID=    678     if countrycode=="STP"
(0 real changes made)

. replace CID=    682     if countrycode=="SAU"
(1 real change made)

. replace CID=    686     if countrycode=="SEN"
(0 real changes made)

. replace CID=    688     if countrycode=="SRB"
(1 real change made)

. replace CID=    690     if countrycode=="SYC"
(0 real changes made)

. replace CID=    694     if countrycode=="SLE"
(0 real changes made)

. replace CID=    702     if countrycode=="SGP"
(0 real changes made)

. replace CID=    703     if countrycode=="SVK"
(0 real changes made)

. replace CID=    705     if countrycode=="SVN"
(0 real changes made)

. replace CID=    90      if countrycode=="SLB"
(0 real changes made)

. replace CID=    706     if countrycode=="SOM"
(0 real changes made)

. replace CID=    710     if countrycode=="ZAF"
(0 real changes made)

. replace CID=    239     if countrycode=="SGS"
(0 real changes made)

. replace CID=    728     if countrycode=="SSD"
(0 real changes made)

. replace CID=    724     if countrycode=="ESP"
(0 real changes made)

. replace CID=    144     if countrycode=="LKA"
(0 real changes made)

. replace CID=    736     if countrycode=="SDN"
(0 real changes made)

. replace CID=    740     if countrycode=="SUR"
(0 real changes made)

. replace CID=    744     if countrycode=="SJM"
(0 real changes made)

. replace CID=    748     if countrycode=="SWZ"
(1 real change made)

. replace CID=    752     if countrycode=="SWE"
(0 real changes made)

. replace CID=    756     if countrycode=="CHE"
(0 real changes made)

. replace CID=    760     if countrycode=="SYR"
(0 real changes made)

. replace CID=    158     if countrycode=="TWN"
(0 real changes made)

. replace CID=    762     if countrycode=="TJK"
(0 real changes made)

. replace CID=    834     if countrycode=="TZA"
(0 real changes made)

. replace CID=    764     if countrycode=="THA"
(0 real changes made)

. replace CID=    626     if countrycode=="TLS"
(0 real changes made)

. replace CID=    768     if countrycode=="TGO"
(0 real changes made)

. replace CID=    772     if countrycode=="TKL"
(0 real changes made)

. replace CID=    776     if countrycode=="TON"
(0 real changes made)

. replace CID=    780     if countrycode=="TTO"
(0 real changes made)

. replace CID=    788     if countrycode=="TUN"
(1 real change made)

. replace CID=    792     if countrycode=="TUR"
(1 real change made)

. replace CID=    795     if countrycode=="TKM"
(0 real changes made)

. replace CID=    796     if countrycode=="TCA"
(0 real changes made)

. replace CID=    798     if countrycode=="TUV"
(0 real changes made)

. replace CID=    800     if countrycode=="UGA"
(1 real change made)

. replace CID=    804     if countrycode=="UKR"
(1 real change made)

. replace CID=    784     if countrycode=="ARE"
(0 real changes made)

. replace CID=    826     if countrycode=="GBR"
(0 real changes made)

. replace CID=    581     if countrycode=="UMI"
(0 real changes made)

. replace CID=    840     if countrycode=="USA"
(1 real change made)

. replace CID=    858     if countrycode=="URY"
(0 real changes made)

. replace CID=    860     if countrycode=="UZB"
(1 real change made)

. replace CID=    548     if countrycode=="VUT"
(0 real changes made)

. replace CID=    862     if countrycode=="VEN"
(1 real change made)

. replace CID=    704     if countrycode=="VNM"
(0 real changes made)

. replace CID=    850     if countrycode=="VIR"
(0 real changes made)

. replace CID=    876     if countrycode=="WLF"
(0 real changes made)

. replace CID=    732     if countrycode=="ESH"
(0 real changes made)

. replace CID=    887     if countrycode=="YEM"
(1 real change made)

. replace CID=    894     if countrycode=="ZMB"
(0 real changes made)

. replace CID=    716     if countrycode=="ZWE"
(0 real changes made)

. 
. 
end of do-file

. tab S003 if CID==.

        ISO 3166-1 numeric country code |      Freq.     Percent        Cum.
----------------------------------------+-----------------------------------
                                Algeria |          1        2.13        2.13
                              Australia |          1        2.13        4.26
                             Bangladesh |          1        2.13        6.38
                     Bosnia Herzegovina |          1        2.13        8.51
                               Bulgaria |          1        2.13       10.64
                                Myanmar |          1        2.13       12.77
                             Taiwan ROC |          1        2.13       14.89
                                Czechia |          1        2.13       17.02
                                 France |          1        2.13       19.15
                                Georgia |          1        2.13       21.28
                                Germany |          1        2.13       23.40
                              Guatemala |          1        2.13       25.53
                                  Haiti |          1        2.13       27.66
                              Indonesia |          1        2.13       29.79
                             Kazakhstan |          1        2.13       31.91
                            South Korea |          1        2.13       34.04
                                 Kuwait |          1        2.13       36.17
                             Kyrgyzstan |          1        2.13       38.30
                                Lebanon |          1        2.13       40.43
                                  Libya |          1        2.13       42.55
                              Macau SAR |          1        2.13       44.68
                               Malaysia |          1        2.13       46.81
                               Maldives |          1        2.13       48.94
                               Mongolia |          1        2.13       51.06
                                Moldova |          1        2.13       53.19
                                Morocco |          1        2.13       55.32
                            Netherlands |          1        2.13       57.45
                            New Zealand |          1        2.13       59.57
                                Nigeria |          1        2.13       61.70
                            Philippines |          1        2.13       63.83
                                Romania |          1        2.13       65.96
                              Singapore |          1        2.13       68.09
                               Slovakia |          1        2.13       70.21
                                Vietnam |          1        2.13       72.34
                           South Africa |          1        2.13       74.47
                               Zimbabwe |          1        2.13       76.60
                                  Spain |          1        2.13       78.72
                                 Sweden |          1        2.13       80.85
                             Tajikistan |          1        2.13       82.98
                               Thailand |          1        2.13       85.11
                    Trinidad and Tobago |          1        2.13       87.23
                         United Kingdom |          1        2.13       89.36
                               Tanzania |          1        2.13       91.49
                           Burkina Faso |          1        2.13       93.62
                                Uruguay |          1        2.13       95.74
                                 Zambia |          1        2.13       97.87
                       Northern Ireland |          1        2.13      100.00
----------------------------------------+-----------------------------------
                                  Total |         47      100.00

. replace CID=S003 if CID==.
(47 real changes made)

. save Trust.dta, replace
file Trust.dta saved

. restore

. merge m:m CID using Trust.dta

    Result                      Number of obs
    -----------------------------------------
    Not matched                           547
        from master                       501  (_merge==1)
        from using                         46  (_merge==2)

    Matched                             1,023  (_merge==3)
    -----------------------------------------

. drop _merge 

. 
. //      #5
. //      corr 
. pwcorr `dv' `iv' `iv2' `cont' KOFGI private_sp public_sp trust notrust 

             |    lrhom   fraser infant~t      edu    unemp popdense perurban
-------------+---------------------------------------------------------------
       lrhom |   1.0000 
      fraser |  -0.3808   1.0000 
  infantmort |   0.5628  -0.4719   1.0000 
         edu |  -0.4535   0.5160  -0.7414   1.0000 
       unemp |   0.0936  -0.1604   0.1866  -0.0696   1.0000 
    popdense |  -0.1947   0.2295  -0.1365   0.0265  -0.1237   1.0000 
    perurban |  -0.2445   0.2983  -0.4809   0.4185  -0.1790   0.2131   1.0000 
    sexratio |  -0.2370  -0.0479  -0.0045  -0.1529  -0.2035   0.0734   0.2091 
       KOFGI |  -0.6072   0.6357  -0.7587   0.7587  -0.1401   0.1201   0.4498 
  private_sp |  -0.2196   0.5065  -0.1684   0.3386  -0.3084   0.2469   0.3121 
   public_sp |  -0.5576   0.1094  -0.5848   0.3351   0.1922  -0.0196  -0.0152 
       trust |  -0.3940   0.4298  -0.4853   0.6442  -0.2273   0.0448   0.3275 
     notrust |   0.3940  -0.4298   0.4853  -0.6442   0.2273  -0.0448  -0.3275 

             | sexratio    KOFGI privat~p public~p    trust  notrust
-------------+------------------------------------------------------
    sexratio |   1.0000 
       KOFGI |  -0.0474   1.0000 
  private_sp |   0.3880   0.3716   1.0000 
   public_sp |   0.0118   0.6795  -0.0252   1.0000 
       trust |  -0.0135   0.6071   0.3451   0.3033   1.0000 
     notrust |   0.0135  -0.6071  -0.3451  -0.3033  -1.0000   1.0000 

. 
. //      #6
. //      Graph 1:  Fraser homicide 
. replace nation="United Kingdom" if CID==826
(20 real changes made)

. replace nation="Venezuela" if CID==862
(17 real changes made)

. 
. graph twoway scatter lrhom fraser

. graph export `file'-lrhomfraser.png, replace 
file MAR09-DescGraph-lrhomfraser.png saved as PNG format

. 
. //      #7
. //      Label CID 
. do label.do

. label define CID        8       "Albania" ///
>         32      "Argentina" ///
>         36      "Australia" ///
>         40      "Austria" ///
>         44      "Bahamas" ///
>         48      "Bahrain" ///
>         51      "Armenia" ///
>         52      "Barbados" ///
>         56      "Belgium" ///
>         76      "Brazil" ///
>         84      "Belize" ///
>         96      "Brunei Darussalam" ///
>         100     "Bulgaria" ///
>         124     "Canada" ///
>         144     "Sri Lanka" ///
>         152     "Chile" ///
>         170     "Colombia" ///
>         188     "Costa Rica" ///
>         191     "Croatia" ///
>         196     "Cyprus" ///
>         203     "Czechia" ///
>         208     "Denmark" ///
>         214     "Dominican Republic" ///
>         218     "Ecuador" ///
>         222     "El Salvador" ///
>         233     "Estonia" ///
>         242     "Fiji" ///
>         246     "Finland" ///
>         250     "France" ///
>         268     "Georgia" ///
>         276     "Germany" ///
>         300     "Greece" ///
>         320     "Guatemala" ///
>         328     "Guyana" ///
>         348     "Hungary" ///
>         352     "Iceland" ///
>         372     "Ireland" ///
>         376     "Israel" ///
>         380     "Italy" ///
>         388     "Jamaica" ///
>         392     "Japan" ///
>         398     "Kazakhstan" ///
>         400     "Jordan" ///
>         410     "Republic of Korea" ///
>         414     "Kuwait" ///
>         417     "Kyrgyzstan" ///
>         428     "Latvia" ///
>         440     "Lithuania" ///
>         442     "Luxembourg" ///
>         458     "Malaysia" ///
>         470     "Malta" ///
>         480     "Mauritius" ///
>         484     "Mexico" ///
>         498     "Republic of Moldova" ///
>         499     "Montenegro" ///
>         512     "Oman" ///
>         528     "Netherlands" ///
>         554     "New Zealand" ///
>         558     "Nicaragua" ///
>         578     "Norway" ///
>         591     "Panama" ///
>         600     "Paraguay" ///
>         604     "Peru" ///
>         608     "Philippines" ///
>         616     "Poland" ///
>         620     "Portugal" ///
>         634     "Qatar" ///
>         642     "Romania" ///
>         643     "Russian Federation" ///
>         688     "Serbia" ///
>         702     "Singapore" ///
>         703     "Slovakia" ///
>         705     "Slovenia" ///
>         710     "South Africa" ///
>         724     "Spain" ///
>         752     "Sweden" ///
>         756     "Switzerland" ///
>         760     "Syrian Arab Republic" ///
>         764     "Thailand" ///
>         780     "Trinidad and Tobago" ///
>         792     "Turkey" ///
>         804     "Ukraine" ///
>         807     "North Macedonia" ///
>         818     "Egypt" ///
>         826     "United Kingdom " ///
>         840     "United States of America" ///
>         858     "Uruguay" ///
>         862     "Venezuela", replace 

. 
end of do-file

. label values CID CID

. tab CID

                     CID |      Freq.     Percent        Cum.
-------------------------+-----------------------------------
                 Albania |          8        0.51        0.51
                      12 |          1        0.06        0.57
                      20 |          1        0.06        0.64
                      31 |          1        0.06        0.70
               Argentina |         20        1.27        1.97
               Australia |         19        1.21        3.18
                 Austria |         20        1.27        4.46
                 Bahamas |         16        1.02        5.48
                 Bahrain |          7        0.45        5.92
                      50 |          1        0.06        5.99
                 Armenia |         14        0.89        6.88
                Barbados |         13        0.83        7.71
                 Belgium |         19        1.21        8.92
                      68 |          1        0.06        8.98
                      70 |          1        0.06        9.04
                  Brazil |         20        1.27       10.32
                  Belize |         17        1.08       11.40
       Brunei Darussalam |          7        0.45       11.85
                Bulgaria |         20        1.27       13.12
                     104 |          1        0.06       13.18
                     112 |          1        0.06       13.25
                  Canada |         20        1.27       14.52
               Sri Lanka |         14        0.89       15.41
                   Chile |         20        1.27       16.69
                     156 |          1        0.06       16.75
                     158 |          1        0.06       16.82
                Colombia |         20        1.27       18.09
              Costa Rica |         20        1.27       19.36
                 Croatia |         19        1.21       20.57
                  Cyprus |         17        1.08       21.66
                 Czechia |         20        1.27       22.93
                 Denmark |         20        1.27       24.20
      Dominican Republic |         19        1.21       25.41
                 Ecuador |         20        1.27       26.69
             El Salvador |         19        1.21       27.90
                     231 |          1        0.06       27.96
                 Estonia |         20        1.27       29.24
                    Fiji |         11        0.70       29.94
                 Finland |         20        1.27       31.21
                  France |         18        1.15       32.36
                 Georgia |         16        1.02       33.38
                     275 |          1        0.06       33.44
                 Germany |         20        1.27       34.71
                     288 |          1        0.06       34.78
                  Greece |         20        1.27       36.05
               Guatemala |         20        1.27       37.32
                  Guyana |         19        1.21       38.54
                     332 |          1        0.06       38.60
                     344 |          1        0.06       38.66
                 Hungary |         20        1.27       39.94
                 Iceland |         18        1.15       41.08
                     356 |          1        0.06       41.15
                     360 |          1        0.06       41.21
                     364 |          1        0.06       41.27
                     368 |          1        0.06       41.34
                 Ireland |         17        1.08       42.42
                  Israel |         20        1.27       43.69
                   Italy |         20        1.27       44.97
                 Jamaica |         13        0.83       45.80
                   Japan |         20        1.27       47.07
              Kazakhstan |         15        0.96       48.03
                  Jordan |          9        0.57       48.60
                     404 |          1        0.06       48.66
       Republic of Korea |         20        1.27       49.94
                  Kuwait |         20        1.27       51.21
              Kyrgyzstan |         15        0.96       52.17
                     422 |          1        0.06       52.23
                  Latvia |         20        1.27       53.50
                     434 |          1        0.06       53.57
               Lithuania |         20        1.27       54.84
              Luxembourg |         20        1.27       56.11
                     446 |          2        0.13       56.24
                Malaysia |         20        1.27       57.52
                     462 |          1        0.06       57.58
                     466 |          1        0.06       57.64
                   Malta |         16        1.02       58.66
               Mauritius |         20        1.27       59.94
                  Mexico |         20        1.27       61.21
                     496 |          2        0.13       61.34
     Republic of Moldova |         14        0.89       62.23
              Montenegro |          6        0.38       62.61
                     504 |          1        0.06       62.68
                    Oman |          6        0.38       63.06
             Netherlands |         20        1.27       64.33
             New Zealand |         17        1.08       65.41
               Nicaragua |         15        0.96       66.37
                     566 |          1        0.06       66.43
                  Norway |         17        1.08       67.52
                     586 |          1        0.06       67.58
                  Panama |         20        1.27       68.85
                Paraguay |         20        1.27       70.13
                    Peru |         20        1.27       71.40
             Philippines |         15        0.96       72.36
                  Poland |         20        1.27       73.63
                Portugal |         17        1.08       74.71
                     630 |          1        0.06       74.78
                   Qatar |          9        0.57       75.35
                 Romania |         20        1.27       76.62
      Russian Federation |         20        1.27       77.90
                     646 |          1        0.06       77.96
                     682 |          1        0.06       78.03
                  Serbia |         15        0.96       78.98
               Singapore |         20        1.27       80.25
                Slovakia |         16        1.02       81.27
                     704 |          1        0.06       81.34
                Slovenia |         20        1.27       82.61
            South Africa |         19        1.21       83.82
                     716 |          1        0.06       83.89
                   Spain |         20        1.27       85.16
                     748 |          1        0.06       85.22
                  Sweden |         19        1.21       86.43
             Switzerland |         20        1.27       87.71
    Syrian Arab Republic |         11        0.70       88.41
                     762 |          1        0.06       88.47
                Thailand |         19        1.21       89.68
     Trinidad and Tobago |         13        0.83       90.51
                     788 |          1        0.06       90.57
                  Turkey |         11        0.70       91.27
                     800 |          1        0.06       91.34
                 Ukraine |         18        1.15       92.48
         North Macedonia |         16        1.02       93.50
                   Egypt |         20        1.27       94.78
         United Kingdom  |         20        1.27       96.05
                     834 |          1        0.06       96.11
United States of America |         20        1.27       97.39
                     854 |          1        0.06       97.45
                 Uruguay |         19        1.21       98.66
                     860 |          1        0.06       98.73
               Venezuela |         17        1.08       99.81
                     887 |          1        0.06       99.87
                     894 |          1        0.06       99.94
                     909 |          1        0.06      100.00
-------------------------+-----------------------------------
                   Total |      1,570      100.00

. 
. //      #8
. //      Graphing by region 
. foreach cid in 32       44      52      76      84      152     170     188   
>   214     218     222     320     328     388     484     558     591     600 
>     604     780     858     862 {
  2.  local v : label (CID) `cid'
  3.  graph twoway connected lrhom fraser year if CID==`cid', title("`v'") name(
> n_`cid', replace)
  4.  graph twoway scatter lrhom fraser if CID==`cid', title("`v'") name(t_`cid'
> , replace)
  5.  
.  }

. graph combine n_32 n_44 n_52 n_76 n_84 n_152 n_170 n_188 n_214 n_218 n_222 n_3
> 20 n_328 n_388 n_484 n_558 n_591 n_600 n_604 n_780 n_858 n_862, altshrink 

. graph export `file'-NLAC.png, replace 
file MAR09-DescGraph-NLAC.png saved as PNG format

. 
. graph combine t_32 t_44 t_52 t_76 t_84 t_152 t_170 t_188 t_214 t_218 t_222 t_3
> 20 t_328 t_388 t_484 t_558 t_591 t_600 t_604 t_780 t_858 t_862, altshrink 

. graph export `file'-TLAC.png, replace 
file MAR09-DescGraph-TLAC.png saved as PNG format

. 
. foreach cid in 48       51      96      144     196     268     376     392   
>   398     400     410     414     417     458     512     608     634     702 
>     760     764     792 {
  2.  local v : label (CID) `cid'
  3.  graph twoway connected lrhom fraser year if CID==`cid', title("`v'") name(
> n_`cid', replace)
  4.  graph twoway scatter lrhom fraser if CID==`cid', title("`v'") name(t_`cid'
> , replace)
  5.  
.  }

. graph combine n_48 n_51 n_96 n_144 n_196 n_268 n_376 n_392 n_398 n_400 n_410 n
> _414 n_417 n_458 n_512 n_608 n_634 n_702 n_760 n_764 n_792

. graph export `file'-NAsia.png, replace 
file MAR09-DescGraph-NAsia.png saved as PNG format

. graph combine t_48 t_51 t_96 t_144 t_196 t_268 t_376 t_392 t_398 t_400 t_410 t
> _414 t_417 t_458 t_512 t_608 t_634 t_702 t_760 t_764 t_792

. graph export `file'-TAsia.png, replace 
file MAR09-DescGraph-TAsia.png saved as PNG format

. 
. foreach cid in 8        40      56      100     191     203     208     233   
>   246     250     276     300     348     352     372     380     428     440 
>     442     470     498     499     528     578     616     620     642     64
> 3     688     703     705     724     752     756     804     807     826 {
  2.         local v : label (CID) `cid'
  3.         graph twoway connected lrhom fraser year if CID==`cid', title("`v'"
> ) name(n_`cid', replace)
  4.  graph twoway scatter lrhom fraser if CID==`cid', title("`v'") name(t_`cid'
> , replace)
  5. }

.  graph combine n_8 n_40 n_56 n_100 n_191 n_203 n_208 n_233 n_246 n_250 n_276 n
> _300 n_348 n_352 n_372 n_380 n_428 n_440 n_442 n_470 n_498 n_499 n_528 n_578 n
> _616 n_620 n_642 n_643 n_688 n_703 n_705 n_724 n_752 n_756 n_804 n_807 n_826 

.  graph export `file'-NEurope.png, replace 
file MAR09-DescGraph-NEurope.png saved as PNG format

. 
. graph combine t_8 t_40 t_56 t_100 t_191 t_203 t_208 t_233 t_246 t_250 t_276 t_
> 300 t_348 t_352 t_372 t_380 t_428 t_440 t_442 t_470 t_498 t_499 t_528 t_578 t_
> 616 t_620 t_642 t_643 t_688 t_703 t_705 t_724 t_752 t_756 t_804 t_807 t_826 

.  graph export `file'-TEurope.png, replace 
file MAR09-DescGraph-TEurope.png saved as PNG format

. 
. 
. foreach cid in 124 840 480 710 818 36 242 554 {
  2.         local v : label (CID) `cid'
  3.         graph twoway connected lrhom fraser year if CID==`cid', title("`v'"
> ) name(n_`cid', replace)
  4.  graph twoway scatter lrhom fraser if CID==`cid', title("`v'") name(t_`cid'
> , replace)
  5. }

. graph combine n_124  n_840  n_480  n_710  n_818  n_36  n_242  n_554

.  graph export `file'-NOther.png, replace 
file MAR09-DescGraph-NOther.png saved as PNG format

. 
. graph combine t_124  t_840  t_480  t_710  t_818  t_36  t_242  t_554

.  graph export `file'-TOther.png, replace 
file MAR09-DescGraph-TOther.png saved as PNG format

. 
. //      #9
. //      Direct effects
. xtreg `dv' `iv' `iv2' `cont', fe cluster(CID) 

Fixed-effects (within) regression               Number of obs     =      1,524
Group variable: CID                             Number of groups  =         88

R-squared:                                      Obs per group:
     Within  = 0.1294                                         min =          6
     Between = 0.3310                                         avg =       17.3
     Overall = 0.3199                                         max =         20

                                                F(7,87)           =      19.36
corr(u_i, Xb) = 0.2209                          Prob > F          =     0.0000

                                   (Std. err. adjusted for 88 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -.2445491   .0870008    -2.81   0.006    -.4174727   -.0716256
  infantmort |   .0044805   .0135865     0.33   0.742    -.0225242    .0314852
         edu |   -2.72643   .8136422    -3.35   0.001    -4.343632   -1.109228
       unemp |   .0035128    .008064     0.44   0.664    -.0125153     .019541
    popdense |  -.0003394   .0001028    -3.30   0.001    -.0005437   -.0001351
    perurban |   .0094687   .0227876     0.42   0.679    -.0358241    .0547615
    sexratio |  -.0122216      .0071    -1.72   0.089    -.0263336    .0018904
       _cons |   5.264567   1.806743     2.91   0.005     1.673471    8.855664
-------------+----------------------------------------------------------------
     sigma_u |  1.1500481
     sigma_e |  .41042354
         rho |  .88702822   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. predict yhat_dir, xb 
(46 missing values generated)

. margins, at(`iv'=(2(2)8))

Predictive margins                                       Number of obs = 1,524
Model VCE: Robust

Expression: Linear prediction, predict()
1._at: fraser = 2
2._at: fraser = 4
3._at: fraser = 6
4._at: fraser = 8

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |    2.18726   .4617043     4.74   0.000     1.282336    3.092183
          2  |   1.698161   .2877027     5.90   0.000     1.134274    2.262048
          3  |   1.209063    .113701    10.63   0.000     .9862132    1.431913
          4  |   .7199649   .0603006    11.94   0.000     .6017779    .8381519
------------------------------------------------------------------------------

. /*
> matrix b=r(b)
> matrix at=r(at)
> 
> * Display the original matrix b
> matrix list b
> * Get dimensions of matrix b
> local rowdim = 1  
> local coldim = 24 
> * Create a new matrix to store the transposed matrix
> matrix b_transposed = J(`coldim', `rowdim', .)
> * Loop through each element of the original matrix and fill the transposed mat
> rix
> forval i = 1 / `rowdim' {
>     forval j = 1 / `coldim' {
>         matrix b_transposed[`j', `i'] = b[`i', `j']
>     }
> }
> 
> 
> matrix list at
> matrix list b_transposed
> */
. 
. xtreg `dv' `iv' `iv2' `cont' if Lfraser==1, fe cluster(CID) 

Fixed-effects (within) regression               Number of obs     =        763
Group variable: CID                             Number of groups  =         66

R-squared:                                      Obs per group:
     Within  = 0.0931                                         min =          1
     Between = 0.1838                                         avg =       11.6
     Overall = 0.1611                                         max =         20

                                                F(7,65)           =       3.54
corr(u_i, Xb) = 0.1664                          Prob > F          =     0.0028

                                   (Std. err. adjusted for 66 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -.3324932   .1036258    -3.21   0.002    -.5394482   -.1255383
  infantmort |   .0128818   .0172085     0.75   0.457    -.0214858    .0472495
         edu |  -.4796209   1.758004    -0.27   0.786    -3.990598    3.031357
       unemp |    .012825   .0121329     1.06   0.294    -.0114061     .037056
    popdense |  -.0002837   .0008366    -0.34   0.736    -.0019544     .001387
    perurban |   .0112829   .0330753     0.34   0.734     -.054773    .0773387
    sexratio |  -.0059394   .0106437    -0.56   0.579    -.0271964    .0153176
       _cons |   3.562738   2.051663     1.74   0.087    -.5347163    7.660193
-------------+----------------------------------------------------------------
     sigma_u |  1.3213019
     sigma_e |  .43940973
         rho |  .90041829   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. predict Lyhat, xb 
(46 missing values generated)

. margins, at(`iv'=(2(2)8))

Predictive margins                                         Number of obs = 763
Model VCE: Robust

Expression: Linear prediction, predict()
1._at: fraser = 2
2._at: fraser = 4
3._at: fraser = 6
4._at: fraser = 8

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   2.953747   .4886029     6.05   0.000     1.996103    3.911392
          2  |   2.288761   .2813514     8.13   0.000     1.737322      2.8402
          3  |   1.623774   .0740999    21.91   0.000     1.478541    1.769008
          4  |    .958788   .1331516     7.20   0.000     .6978156     1.21976
------------------------------------------------------------------------------

. 
. /*
> matrix b=r(b)
> matrix at=r(at)
> 
> * Display the original matrix b
> matrix list b
> * Get dimensions of matrix b
> local rowdim = 1  
> local coldim = 24 
> * Create a new matrix to store the transposed matrix
> matrix b_transposed = J(`coldim', `rowdim', .)
> * Loop through each element of the original matrix and fill the transposed mat
> rix
> forval i = 1 / `rowdim' {
>     forval j = 1 / `coldim' {
>         matrix b_transposed[`j', `i'] = b[`i', `j']
>     }
> }
> 
> 
> matrix list at
> matrix list b_transposed
> */
. xtreg `dv' `iv' `iv2' `cont' if Lfraser==0, fe cluster(CID) 

Fixed-effects (within) regression               Number of obs     =        761
Group variable: CID                             Number of groups  =         54

R-squared:                                      Obs per group:
     Within  = 0.2420                                         min =          1
     Between = 0.3933                                         avg =       14.1
     Overall = 0.3176                                         max =         20

                                                F(7,53)           =      78.77
corr(u_i, Xb) = 0.0115                          Prob > F          =     0.0000

                                   (Std. err. adjusted for 54 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -.1404501   .2151207    -0.65   0.517    -.5719277    .2910274
  infantmort |    .014118   .0267602     0.53   0.600    -.0395561    .0677921
         edu |   -3.95014   .6338082    -6.23   0.000    -5.221398   -2.678882
       unemp |  -.0059967   .0080663    -0.74   0.461    -.0221756    .0101822
    popdense |   .0001058   .0001693     0.62   0.535    -.0002338    .0004455
    perurban |   .0010761   .0225967     0.05   0.962    -.0442471    .0463994
    sexratio |  -.1064746   .0427612    -2.49   0.016    -.1922426   -.0207066
       _cons |   14.79839   4.912095     3.01   0.004     4.945978    24.65081
-------------+----------------------------------------------------------------
     sigma_u |  .91119927
     sigma_e |  .34232457
         rho |  .87631684   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. predict Hyhat, xb 
(46 missing values generated)

. margins, at(`iv'=(2(2)8))

Predictive margins                                         Number of obs = 761
Model VCE: Robust

Expression: Linear prediction, predict()
1._at: fraser = 2
2._at: fraser = 4
3._at: fraser = 6
4._at: fraser = 8

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   1.220297   1.269272     0.96   0.336     -1.26743    3.708024
          2  |    .939397   .8390302     1.12   0.263    -.7050721    2.583866
          3  |   .6584967   .4087888     1.61   0.107    -.1427145    1.459708
          4  |   .3775964   .0214527    17.60   0.000     .3355499     .419643
------------------------------------------------------------------------------

. 
. graph twoway (lfit yhat_dir fraser) (lfit Lyhat fraser) (lfit Hyhat fraser), /
> //
>         xtitle("Fraser") ytitle("Predicted Ln Homicide Rates per 100k pop") //
> /
>         note("Best fit line | `note'") legend(label(1 "Fraser") label(2 "Low F
> raser") label(3 "High Fraser"))

. graph export `file'-FraserDirect.png, replace 
file MAR09-DescGraph-FraserDirect.png saved as PNG format

. 
. //      #10
. //      Moderating effects Set up for graphing 
. xtreg `dv' c.`iv'##c.`iv2' c.`iv'##c.lgdp `cont', fe cluster(CID) 
note: fraser omitted because of collinearity.

Fixed-effects (within) regression               Number of obs     =      1,507
Group variable: CID                             Number of groups  =         87

R-squared:                                      Obs per group:
     Within  = 0.1809                                         min =          6
     Between = 0.2773                                         avg =       17.3
     Overall = 0.2812                                         max =         20

                                                F(10,86)          =      20.33
corr(u_i, Xb) = -0.1436                         Prob > F          =     0.0000

                                   (Std. err. adjusted for 87 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -4.027198   1.135337    -3.55   0.001    -6.284173   -1.770223
  infantmort |  -.2513516   .1085426    -2.32   0.023    -.4671273    -.035576
             |
    c.fraser#|
c.infantmort |   .0348964   .0163778     2.13   0.036     .0023384    .0674544
             |
      fraser |          0  (omitted)
        lgdp |  -3.345676   .7350785    -4.55   0.000    -4.806964   -1.884389
             |
    c.fraser#|
      c.lgdp |   .3779155   .1081273     3.50   0.001     .1629656    .5928654
             |
         edu |  -1.601994   1.109652    -1.44   0.152    -3.807909    .6039204
       unemp |  -.0086621   .0095003    -0.91   0.364    -.0275479    .0102238
    popdense |  -.0004381   .0001217    -3.60   0.001    -.0006799   -.0001962
    perurban |   .0130069   .0192879     0.67   0.502    -.0253363      .05135
    sexratio |  -.0161678   .0077678    -2.08   0.040    -.0316096   -.0007259
       _cons |   37.78911   7.189683     5.26   0.000     23.49649    52.08172
-------------+----------------------------------------------------------------
     sigma_u |  1.1738731
     sigma_e |  .40054024
         rho |  .89571544   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. margins, at(`iv2'=(1(10)51) `iv'=(2(2)8))

Predictive margins                                       Number of obs = 1,507
Model VCE: Robust

Expression: Linear prediction, predict()
1._at:  fraser     =  2
        infantmort =  1
2._at:  fraser     =  2
        infantmort = 11
3._at:  fraser     =  2
        infantmort = 21
4._at:  fraser     =  2
        infantmort = 31
5._at:  fraser     =  2
        infantmort = 41
6._at:  fraser     =  2
        infantmort = 51
7._at:  fraser     =  4
        infantmort =  1
8._at:  fraser     =  4
        infantmort = 11
9._at:  fraser     =  4
        infantmort = 21
10._at: fraser     =  4
        infantmort = 31
11._at: fraser     =  4
        infantmort = 41
12._at: fraser     =  4
        infantmort = 51
13._at: fraser     =  6
        infantmort =  1
14._at: fraser     =  6
        infantmort = 11
15._at: fraser     =  6
        infantmort = 21
16._at: fraser     =  6
        infantmort = 31
17._at: fraser     =  6
        infantmort = 41
18._at: fraser     =  6
        infantmort = 51
19._at: fraser     =  8
        infantmort =  1
20._at: fraser     =  8
        infantmort = 11
21._at: fraser     =  8
        infantmort = 21
22._at: fraser     =  8
        infantmort = 31
23._at: fraser     =  8
        infantmort = 41
24._at: fraser     =  8
        infantmort = 51

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   2.928058   .7428399     3.94   0.000     1.472119    4.383998
          2  |   1.112469   .4802462     2.32   0.021     .1712041    2.053735
          3  |  -.7031195   1.033018    -0.68   0.496    -2.727798    1.321559
          4  |  -2.518708   1.749652    -1.44   0.150    -5.947964     .910547
          5  |  -4.334297    2.49261    -1.74   0.082    -9.219723    .5511284
          6  |  -6.149886   3.243854    -1.90   0.058    -12.50772    .2079515
          7  |   2.109801   .4414673     4.78   0.000      1.24454    2.975061
          8  |   .9921391   .3023046     3.28   0.001     .3996329    1.584645
          9  |  -.1255222   .6132564    -0.20   0.838    -1.327483    1.076438
         10  |  -1.243184   1.024197    -1.21   0.225    -3.250574    .7642063
         11  |  -2.360845   1.452611    -1.63   0.104    -5.207909    .4862195
         12  |  -3.478506   1.886631    -1.84   0.065    -7.176235    .2192221
         13  |   1.291543   .1695298     7.62   0.000     .9592706    1.623815
         14  |   .8718089   .1268175     6.87   0.000     .6232512    1.120367
         15  |   .4520751   .2265678     2.00   0.046     .0080103    .8961398
         16  |   .0323412    .366731     0.09   0.930    -.6864385    .7511208
         17  |  -.3873927   .5153226    -0.75   0.452    -1.397406     .622621
         18  |  -.8071266    .666732    -1.21   0.226    -2.113897     .499644
         19  |   .4732852   .2309804     2.05   0.040     .0205718    .9259985
         20  |   .7514788   .0687033    10.94   0.000     .6168228    .8861347
         21  |   1.029672   .3047536     3.38   0.001     .4323662    1.626978
         22  |   1.307866   .5637516     2.32   0.020     .2029331    2.412799
         23  |    1.58606   .8243442     1.92   0.054    -.0296255    3.201745
         24  |   1.864253   1.085384     1.72   0.086    -.2630595    3.991566
------------------------------------------------------------------------------

. /*
> matrix b=r(b)
> matrix at=r(at)
> 
> * Display the original matrix b
> matrix list b
> * Get dimensions of matrix b
> local rowdim = 1  
> local coldim = 24 
> * Create a new matrix to store the transposed matrix
> matrix b_transposed = J(`coldim', `rowdim', .)
> * Loop through each element of the original matrix and fill the transposed mat
> rix
> forval i = 1 / `rowdim' {
>     forval j = 1 / `coldim' {
>         matrix b_transposed[`j', `i'] = b[`i', `j']
>     }
> }
> 
> 
> matrix list at
> matrix list b_transposed
> */
. 
. margins, at(lgdp=(6(2)12) `iv'=(2(2)8))

Predictive margins                                       Number of obs = 1,507
Model VCE: Robust

Expression: Linear prediction, predict()
1._at:  fraser =  2
        lgdp   =  6
2._at:  fraser =  2
        lgdp   =  8
3._at:  fraser =  2
        lgdp   = 10
4._at:  fraser =  2
        lgdp   = 12
5._at:  fraser =  4
        lgdp   =  6
6._at:  fraser =  4
        lgdp   =  8
7._at:  fraser =  4
        lgdp   = 10
8._at:  fraser =  4
        lgdp   = 12
9._at:  fraser =  6
        lgdp   =  6
10._at: fraser =  6
        lgdp   =  8
11._at: fraser =  6
        lgdp   = 10
12._at: fraser =  6
        lgdp   = 12
13._at: fraser =  8
        lgdp   =  6
14._at: fraser =  8
        lgdp   =  8
15._at: fraser =  8
        lgdp   = 10
16._at: fraser =  8
        lgdp   = 12

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   10.23248   1.774755     5.77   0.000     6.754026    13.71094
          2  |   5.052791     .74691     6.76   0.000     3.588874    6.516707
          3  |  -.1268996   .6453369    -0.20   0.844    -1.391737    1.137937
          4  |   -5.30659   1.650912    -3.21   0.001    -8.542318   -2.070862
          5  |   7.440931   1.328604     5.60   0.000     4.836915    10.04495
          6  |   3.772903   .5565571     6.78   0.000     2.682071    4.863735
          7  |   .1048743   .4251906     0.25   0.805     -.728484    .9382326
          8  |  -3.563154   1.174002    -3.04   0.002    -5.864157   -1.262152
          9  |   4.649381   1.178212     3.95   0.000     2.340128    6.958633
         10  |   2.493014   .4975059     5.01   0.000     1.517921    3.468108
         11  |   .3366482   .2399167     1.40   0.161    -.1335799    .8068763
         12  |  -1.819718   .9046141    -2.01   0.044    -3.592729   -.0467071
         13  |   1.857831   1.420823     1.31   0.191    -.9269316    4.642593
         14  |   1.213126   .6092155     1.99   0.046      .019086    2.407167
         15  |   .5684221   .2162847     2.63   0.009     .1445119    .9923323
         16  |  -.0762821   1.022568    -0.07   0.941    -2.080478    1.927914
------------------------------------------------------------------------------

. /*
> matrix b=r(b)
> matrix at=r(at)
> 
> * Display the original matrix b
> matrix list b
> * Get dimensions of matrix b
> local rowdim = 1  
> local coldim = 16 
> * Create a new matrix to store the transposed matrix
> matrix b_transposed = J(`coldim', `rowdim', .)
> * Loop through each element of the original matrix and fill the transposed mat
> rix
> forval i = 1 / `rowdim' {
>     forval j = 1 / `coldim' {
>         matrix b_transposed[`j', `i'] = b[`i', `j']
>     }
> }
> 
> 
> matrix list at
> matrix list b_transposed
> */
. 
. 
. xtreg `dv'  c.`iv'##c.lgdp `iv2' `cont', fe cluster(CID) 

Fixed-effects (within) regression               Number of obs     =      1,507
Group variable: CID                             Number of groups  =         87

R-squared:                                      Obs per group:
     Within  = 0.1595                                         min =          6
     Between = 0.2789                                         avg =       17.3
     Overall = 0.2798                                         max =         20

                                                F(9,86)           =      21.00
corr(u_i, Xb) = -0.2075                         Prob > F          =     0.0000

                                   (Std. err. adjusted for 87 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -1.687684   .6993717    -2.41   0.018    -3.077988   -.2973786
        lgdp |  -2.049407   .6166664    -3.32   0.001      -3.2753   -.8235152
             |
    c.fraser#|
      c.lgdp |   .1694942   .0735323     2.31   0.024     .0233168    .3156717
             |
  infantmort |  -.0129424   .0141918    -0.91   0.364    -.0411547      .01527
         edu |  -1.642303   1.159215    -1.42   0.160    -3.946746    .6621403
       unemp |  -.0086718   .0097325    -0.89   0.375    -.0280193    .0106756
    popdense |  -.0003182   .0001257    -2.53   0.013    -.0005681   -.0000682
    perurban |   .0146533   .0240748     0.61   0.544    -.0332058    .0625124
    sexratio |  -.0181164   .0079225    -2.29   0.025    -.0338658    -.002367
       _cons |   23.09045    6.39643     3.61   0.001     10.37477    35.80613
-------------+----------------------------------------------------------------
     sigma_u |  1.1941626
     sigma_e |  .40558952
         rho |  .89657338   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. margins, at(lgdp=(6(2)12) `iv'=(2(2)8))

Predictive margins                                       Number of obs = 1,507
Model VCE: Robust

Expression: Linear prediction, predict()
1._at:  fraser =  2
        lgdp   =  6
2._at:  fraser =  2
        lgdp   =  8
3._at:  fraser =  2
        lgdp   = 10
4._at:  fraser =  2
        lgdp   = 12
5._at:  fraser =  4
        lgdp   =  6
6._at:  fraser =  4
        lgdp   =  8
7._at:  fraser =  4
        lgdp   = 10
8._at:  fraser =  4
        lgdp   = 12
9._at:  fraser =  6
        lgdp   =  6
10._at: fraser =  6
        lgdp   =  8
11._at: fraser =  6
        lgdp   = 10
12._at: fraser =  6
        lgdp   = 12
13._at: fraser =  8
        lgdp   =  6
14._at: fraser =  8
        lgdp   =  8
15._at: fraser =  8
        lgdp   = 10
16._at: fraser =  8
        lgdp   = 12

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   7.167012   1.765556     4.06   0.000     3.706584    10.62744
          2  |   3.746173   .8470915     4.42   0.000     2.085905    5.406442
          3  |   .3253354    .592159     0.55   0.583     -.835275    1.485946
          4  |  -3.095503   1.420019    -2.18   0.029    -5.878689   -.3123162
          5  |   5.825575   1.434399     4.06   0.000     3.014205    8.636946
          6  |   3.082714   .6521894     4.73   0.000     1.804446    4.360982
          7  |   .3398531   .4030601     0.84   0.399    -.4501302    1.129836
          8  |  -2.403008   1.126419    -2.13   0.033    -4.610749   -.1952671
          9  |   4.484139   1.254997     3.57   0.000     2.024389    6.943889
         10  |   2.419255   .5390004     4.49   0.000     1.362834    3.475676
         11  |   .3543707   .2405644     1.47   0.141    -.1171267    .8258682
         12  |  -1.710513    .936519    -1.83   0.068    -3.546057    .1250301
         13  |   3.142703   1.292185     2.43   0.015     .6100662     5.67534
         14  |   1.755796   .5595313     3.14   0.002     .6591344    2.852457
         15  |   .3688884    .192077     1.92   0.055    -.0075756    .7453524
         16  |  -1.018019   .9171683    -1.11   0.267    -2.815636    .7795981
------------------------------------------------------------------------------

. /*
> matrix b=r(b)
> matrix at=r(at)
> 
> * Display the original matrix b
> matrix list b
> * Get dimensions of matrix b
> local rowdim = 1  
> local coldim = 16 
> * Create a new matrix to store the transposed matrix
> matrix b_transposed = J(`coldim', `rowdim', .)
> * Loop through each element of the original matrix and fill the transposed mat
> rix
> forval i = 1 / `rowdim' {
>     forval j = 1 / `coldim' {
>         matrix b_transposed[`j', `i'] = b[`i', `j']
>     }
> }
> 
> 
> matrix list at
> matrix list b_transposed
> */
. 
. //      #10
. //      Data for moderating effects (obtained from above) 
. preserve 

. insheet using 00-Market-InteractionData.csv, comma clear n
(9 vars, 24 obs)

. graph twoway (connected yhat_infantxfraser infantmort if fraser==2, msymbol(i)
>  lpatter(solid) lcolor(black)) ///
>         (connected yhat_infantxfraser infantmort if fraser==8, msymbol(i)  lpa
> tter(dash_dot) lcolor(black)), ///
>         ytitle("Predicted Ln Homicide Rates per 100k pop") xtitle("Infant Mort
> ality Rates") ///
>         title("Fraser X Infant Mortality") name(FXI, replace) ///
>         legend(label(1 "Low Fraser") label(2 "High Fraser"))

.         
.         
. graph twoway (connected yhat_gdpfraser lgdp if fraser==2, msymbol(i) lpatter(s
> olid) lcolor(black)) ///
>         (connected yhat_gdpfraser lgdp if fraser==8, msymbol(i)  lpatter(dash_
> dot) lcolor(black)), ///
>         ytitle("Predicted Ln Homicide Rates per 100k pop") xtitle("Ln GDP") //
> /
>         title("Ln GDP X Fraser") name(FXG, replace) ///
>         legend(label(1 "Low Fraser") label(2 "High Fraser"))

. 
. graph combine FXI FXG, altshrink  ycommon

. graph export `file'-interaction.png, replace 
file MAR09-DescGraph-interaction.png saved as PNG format

. 
. graph twoway connected  yhat_fraserdir yhat_lowfraser yhat_highfraser fraser, 
> ///
>         ytitle("Predicted Ln Homicide Rates per 100k pop") xtitle("Fraser") //
> /
>         legend(label 1 ("Fraser") label(2 "Low Fraser") label(3 "High Fraser")
> ) ///
>         note("Predicted Prob ||`note'") 
option label not allowed
r(198);

end of do-file

r(198);

. help xtreg

. do "C:\Users\MEGHRO~1\AppData\Local\Temp\STD3e70_000000.tmp"

. local tag " 06-29-24| Cleaned 06-29-24"

. local file "MAR09-DescGraph"

. local note "|`tag' | `file'"

. local opt "noparen sideway excel noaster  bdec(2)  sdec(2)  pdec(3)   adec(2) 
> e(r2) stats(coef se pval)"

. local dv "lrhom"

. local iv "fraser"

. local iv2 "infantmort" 

. local cont "edu unemp  popdense perurban  sexratio"

. 
. graph twoway connected  yhat_fraserdir yhat_lowfraser yhat_highfraser fraser, 
> ///
>         ytitle("Predicted Ln Homicide Rates per 100k pop") xtitle("Fraser") //
> /
>         legend(label (1 "Fraser") label(2 "Low Fraser") label(3 "High Fraser")
> ) ///
>         note("Predicted Prob ||`note'") 
variable yhat_fraserdir not found
r(111);

end of do-file

r(111);

. do "C:\Users\MEGHRO~1\AppData\Local\Temp\STD3e70_000000.tmp"

. local tag " 06-29-24| Cleaned 06-29-24"

. local file "MAR09-DescGraph"

. local note "|`tag' | `file'"

. local opt "noparen sideway excel noaster  bdec(2)  sdec(2)  pdec(3)   adec(2) 
> e(r2) stats(coef se pval)"

. local dv "lrhom"

. local iv "fraser"

. local iv2 "infantmort" 

. local cont "edu unemp  popdense perurban  sexratio"

. 
. preserve 

. insheet using 00-Market-InteractionData.csv, comma clear n
(9 vars, 24 obs)

. graph twoway (connected yhat_infantxfraser infantmort if fraser==2, msymbol(i)
>  lpatter(solid) lcolor(black)) ///
>         (connected yhat_infantxfraser infantmort if fraser==8, msymbol(i)  lpa
> tter(dash_dot) lcolor(black)), ///
>         ytitle("Predicted Ln Homicide Rates per 100k pop") xtitle("Infant Mort
> ality Rates") ///
>         title("Fraser X Infant Mortality") name(FXI, replace) ///
>         legend(label(1 "Low Fraser") label(2 "High Fraser"))

.         
.         
. graph twoway (connected yhat_gdpfraser lgdp if fraser==2, msymbol(i) lpatter(s
> olid) lcolor(black)) ///
>         (connected yhat_gdpfraser lgdp if fraser==8, msymbol(i)  lpatter(dash_
> dot) lcolor(black)), ///
>         ytitle("Predicted Ln Homicide Rates per 100k pop") xtitle("Ln GDP") //
> /
>         title("Ln GDP X Fraser") name(FXG, replace) ///
>         legend(label(1 "Low Fraser") label(2 "High Fraser"))

. 
. graph combine FXI FXG, altshrink  ycommon

. graph export `file'-interaction.png, replace 
file MAR09-DescGraph-interaction.png saved as PNG format

. 
. graph twoway connected  yhat_fraserdir yhat_lowfraser yhat_highfraser fraser, 
> ///
>         ytitle("Predicted Ln Homicide Rates per 100k pop") xtitle("Fraser") //
> /
>         legend(label (1 "Fraser") label(2 "Low Fraser") label(3 "High Fraser")
> ) ///
>         note("Predicted Prob ||`note'") 

. graph export `file'-direct2.png, replace 
(file MAR09-DescGraph-direct2.png not found)
file MAR09-DescGraph-direct2.png saved as PNG format

. restore 

. //      #11
. //      save 
. save `file'.dta, replace 
file MAR09-DescGraph.dta saved

. 
. //      #12
. //      Cleaning up for R 
. keep  CID nation year regioncode regionname countrycode rhom `dv' `iv' `iv2' `
> cont' lgdp gdp KOFGI heritage rol LAC Lfraser trust notrust yhat_dir Lyhat Hyh
> at

. saveold `file'-old.dta, v(11) replace 
(saving in Stata 12 format, which Stata 11 can read)
(file MAR09-DescGraph-old.dta not found)
file MAR09-DescGraph-old.dta saved

. log close 
      name:  <unnamed>
       log:  R:\Current Research\Markets-Pridemore\Work\MAR09-DescGraph.log
  log type:  text
 closed on:   1 Jul 2024, 16:15:43
--------------------------------------------------------------------------------
